package net;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class docghi extends Thread{
	private ObjectInputStream in;
	
	
	private Queues<msg> cmdqueue;
	public docghi(ObjectInputStream in, Queues<msg> cmdqueue)
	{
		super();
		this.in=in;
		
		this.cmdqueue=cmdqueue;
		
	}
public void run()
{
	
	while(true)
	{
		
		
		try {
			msg ms=(msg)in.readObject();
			if(ms.getType().equals(new MSGType().getDISCONNECTED())&& (!ms.getStr().equals("client")))
			{
				
				break;
			}
			cmdqueue.enqueue(ms);//doc data upload for UI
			//System.out.println("toi da thuc hien song doc vao cmdqueue");
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try {
			Thread.sleep(200);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
}
}
